package com.itheima.pool;

import java.util.concurrent.*;

public class Demo03 {

    public static void main(String[] args) {

        ThreadPoolExecutor pool = new ThreadPoolExecutor(5, 10, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>(5),Executors.defaultThreadFactory(),new ThreadPoolExecutor.CallerRunsPolicy());
        for (int  i=0;i<100;i++) {
          final  int j=i;
            pool.submit(()->{
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+"正在被执行活"+j);
            });
        }
    }
}
